

package com.hm.jiaowuxitong.ui;

        import com.hm.jiaowuxitong.service.IStudentService;
        import com.hm.jiaowuxitong.service.StudentServiceImp;
        import com.hm.jiaowuxitong.util.DataUtil;
        import com.hm.jiaowuxitong.util.UIUtil;

        import javax.swing.*;
        import java.awt.*;
        import java.util.List;
        import java.util.Map;

public class TeacherCourseInfoUI {
    private Object[] columnNames={"周一","周二","周三","周四","周五","周六"};




    public TeacherCourseInfoUI(){
        //创建面板
        JFrame frame=new JFrame("课表");

        //滚动画布
        JScrollPane pane=null;


        Object[][] objects = {
                {"离散", "", "","","","高数"},
                {"", "   ", "离散","离散","",""},
                {"  ", "高数", "","","","英语"},
                {"", "离散", "","","",""},
                {"", "", "高数","","英语",""},
                {"", "", "","","","英语"},

        };

        //判断是否获得了数据
        if (objects.length>0){
            //从数据库中拿到了数据
            //将数据展示出来
            JTable table=new JTable(objects,columnNames);
            // 给表格设置行高
            table.setRowHeight(150); // 设置行高为30像素，根据需要调整具体数值



            //给表格每一列进行设定宽度
            for (int i = 0; i < columnNames.length; i++) {
                table.getColumnModel().getColumn(i).setPreferredWidth(70);
            }
            pane=new JScrollPane(table);
        }else {
            //数据库中没有任何人员信息
            JLabel label=new JLabel("暂无人员详细信息");
            pane=new JScrollPane(label);
        }
        //将画布添加至面板，并且设置居中显示
        frame.getContentPane().add(pane, BorderLayout.CENTER);
        //让面板根据添加的控件的内容进行自适应
        frame.pack();
        //获得面板的当前宽高
        //让面板显示在屏幕中央
        new UIUtil().center(frame,frame.getWidth(),frame.getHeight());
        frame.setSize(1000, 800);
        //显示面板
        frame.setVisible(true);

    }

    public static void main(String[] args) {
        new TeacherCourseInfoUI();
    }
}
